/*
 * @Author: chen haoxuan
 * @Date: 2021-06-18 22:31:28
 * @LastEditTime: 2021-06-18 22:41:30
 */
#include <iostream>
#include <math.h>
using namespace std;
class Shape
{
public:
  virtual void area(){
    cout<<" "<<endl;
  }
};
// Cirele 圆形
class Circle : public Shape
{
public:
  void area();
  Circle(float r):radius(r){}
private:
  float radius;
};
void Circle::area()
{
  float area;
  area = 3.14159 * radius * radius;
  cout << "The area of circle is: " << area << endl;
}
// Rectangle 矩形
class Rectangle : public Shape
{
public:
  void area();
  Rectangle(int w,int l):width(w),length(l){}
private:
  float width;
  float length;
};
void Rectangle::area()
{
  float area;
  area = width * length;
  cout << "The area of rectangle is: " << area << endl;
}

// 三角形
class Triangle : public Shape
{
public:
  void area();
  Triangle(int a,int b,int c):a(a),b(b),c(c){}
private:
  float a;
  float b;
  float c;
};
void Triangle::area()
{
  float l;
  l = (a + b + c) / 2;
  float area = sqrt(l * (l - a) * (l - b) * (l - c));
  cout << "The area of Triangle is: " << area << endl;
}

int main()
{
  Shape *p=new Shape;
  Circle circle1(2);
  p=&circle1;
  p->area();
  Rectangle re(2,4);
  p=&re;
  p->area();
  Triangle t1(3,4,5);
  p=&t1;
  p->area();
  system("pause");
  return 0;
}